//microcommand define balance
inject(["monetary"])
const currencies = ["default"]
const bonusCurrencies = ["bonus"]
signature("[user:user]", { checkArgCount: true, checkUnknown: true })
action(async ({ session }, user) => {
let uid
if (user) {
const platform = user.split(":")[0]
const [binding] = await ctx.database.get("binding", { platform, pid: user.slice(platform.length + 1) }, ["aid"])
if (!binding) return session.text("admin.user-not-found")
uid = binding.aid
} else {
uid = session.user.id
}
let data = await ctx.monetary.query(uid, currencies.concat(bonusCurrencies))
const reportCurrencies = currencies.concat(bonusCurrencies.filter(c => Object.hasOwn(data, c)))
const lines = reportCurrencies.map(c => session.i18n(".entry", { currency: session.i18n([`.currency.${c}`, ""]) || c, value: data[c] || 0 }))
const joinedLines = [...lines[0]]
for (const line of lines.slice(1)) joinedLines.push(...session.i18n(".entry-separator"), ...line)
const result = session.i18n(".result", { uid, "0": joinedLines })
return session.isDirect ? result : [h.quote(session.messageId), ...result]
})
locale("zh-CN", { description: "查询当前拥有的点数", messages: { "result": "用户序号：{uid}<br/>{0}", entry: "{currency}：{value}", "entry-separator": "<br/>", currency: { default: "点数", bonus: "点数消耗减免额度" } } })